Conversation
… tracking Implements Phase 3 of Epic #21 (Document Analysis MCP Server): ## New Tools - **pdf_ocr** - OCR for scanned PDFs using Tesseract - Automatic fallback when text extraction fails - Configurable language and DPI - Force OCR option for guaranteed image-to-text - **pdf_extract_structure** - Document structure extraction - Table of Contents (TOC) detection - Table extraction with markdown formatting - Section/heading hierarchy detection ## New Modules - **cache/** - Hash-based document caching - SHA-256 content hashing for deduplication - Configurable TTL via CACHE_TTL_DAYS env - Automatic cleanup of expired entries - Parameter-aware cache keys for different tool configs - **tracking/** - API usage tracking - Token usage logging per operation - Cost estimation by model - Daily summary reports ## Additional Tools - **cache_stats** - View cache statistics - **usage_summary** - View API usage and costs ## Version - Bumped to v0.3.0 Closes krisoye/project-tracker#96 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
krisoye13
approved these changes
Feb 2, 2026
krisoye
pushed a commit
that referenced
this pull request
Feb 2, 2026
- Add file locking (fcntl) to cache metadata operations for concurrent access - Add threading.Lock for in-memory cache metadata protection - Add file locking to usage tracking append and read operations - Add language parameter validation for OCR tool with VALID_LANGUAGES set - Add atomic metadata writes using temp file + rename pattern - Add comprehensive concurrent operation tests for cache and tracking Thread safety improvements: - Cache: _save_metadata() uses exclusive lock with atomic write - Cache: _load_metadata() uses shared lock for concurrent reads - Cache: All metadata modifications protected by threading.Lock - Tracking: record() uses exclusive lock for append operations - Tracking: get_records() uses shared lock for read operations Input validation: - OCR: Invalid language codes log warning and fall back to "eng" - OCR: VALID_LANGUAGES includes 28 common Tesseract language codes Fixes issues identified in QA review of PR #9 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
krisoye13
added a commit
that referenced
this pull request
Feb 2, 2026
- Add file locking (fcntl) to cache metadata operations for concurrent access - Add threading.Lock for in-memory cache metadata protection - Add file locking to usage tracking append and read operations - Add language parameter validation for OCR tool with VALID_LANGUAGES set - Add atomic metadata writes using temp file + rename pattern - Add comprehensive concurrent operation tests for cache and tracking Thread safety improvements: - Cache: _save_metadata() uses exclusive lock with atomic write - Cache: _load_metadata() uses shared lock for concurrent reads - Cache: All metadata modifications protected by threading.Lock - Tracking: record() uses exclusive lock for append operations - Tracking: get_records() uses shared lock for read operations Input validation: - OCR: Invalid language codes log warning and fall back to "eng" - OCR: VALID_LANGUAGES includes 28 common Tesseract language codes Fixes issues identified in QA review of PR #9 Co-authored-by: Krisoye Smith <krisoye@gmail.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements Phase 3 of Epic #21 (Document Analysis MCP Server) with advanced features:
Changes
New Tools
pdf_ocrpdf_extract_structurecache_statsusage_summaryNew Modules
src/document_analysis_mcp/cache/__init__.py- Hash-based cachingsrc/document_analysis_mcp/tracking/__init__.py- Usage trackingsrc/document_analysis_mcp/tools/ocr.py- OCR toolsrc/document_analysis_mcp/tools/structure.py- Structure extractionUpdated Files
server.py- Register new tools, v0.3.0pyproject.toml- Version bumpTests
Test Plan
Closes krisoye/project-tracker#96
Generated with Claude Code